/**
 * 
 */
package leetCode;

/**
 * @author zhong
 *
 */
public class MinCostClimbingStairs {
	public int minCostClimbingStairs(int[] cost) {
		int n = cost.length;
		int[] dp = new int[n];
		dp[0] = cost[0];
		dp[1] = cost[1];
		for (int i = 2; i < dp.length; i++) {
			dp[i] = cost[i] + Math.min(dp[i - 1], dp[i - 2]);
		}
		return Math.min(dp[n - 1], dp[n - 2]);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int[] cost = { 10, 15 };
		System.out.println(new MinCostClimbingStairs().minCostClimbingStairs(cost));
	}

}
